home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Programming / AMOSList / AMOSLIST / text0065.txt < prev    next >
Encoding:
Text File  |  1998-04-01  |  1.4 KB  |  31 lines

  1. > Here's a little trick I found the other day, hope somebody can use it..
  2. > To store an integer-array you would normaly open a sequentiel file
  3. > and dump the data with a loop.. Well try this instead:
  4. > MX=50
  5. > Dim A(MX)
  6. > Bsave FILE$,Varptr(A(0)) To Varptr(A(0))+(MX+1)*4
  7. > And to reload:
  8. > Bload FILE$,Varptr(A(0))
  9. > You can simply replace Bsave with Ssave if you'd like to have more
  10. > than one Array in a file. Or use Copy to put in a bank :)
  11.  
  12.    Yes, this is very efficient and is the method I used in my SideShooter
  13.    stage for loading the arrays with file-data.  MUCH faster than the
  14.    standard "loop and load" approach and just all-round more 
  15.    efficient, so I'd recommend using this as well... besides, once you're
  16.    used to seeing everything as binary-data (which everything is in
  17.    the end), you can move between languages like AMOS, C, 
  18.    Assembler, etc. much easier. :-)
  19.  
  20.    Another thing to consider is writing a small array-to-binary
  21.    convertor as many times you don't need 32-bit (long word) values.
  22.    For example, I ran the scrolling-map (used in the SideShooter)
  23.    through a simple convertor I threw together which saved out an
  24.    8-bit binary data file, resulting in the map file size decreasing to
  25.    just 25% of it's original size and loading MUCH faster as well. ;-)
  26.   
  27.  
  28.                 Garfield Benjamin    e-mail:gbenjam@sosbbs.com
  29.         Website( http://www.sosbbs.com/~gbenjam ): 50% Complete
  30.  
  31.